import Vue from 'vue'

import Vuex from 'vuex'

Vue.use(Vuex)
const store = new Vuex.Store({
    state: {
		token:uni.getStorageSync('token') || '',
		user: uni.getStorageSync('user') || {},
	},
    mutations: {
		//设置用户信息
		setuser(state,user){
			state.user = user
			uni.setStorageSync('user',user)
		},
		//设置token
		settoken(state,token){
			state.token = token
			uni.setStorageSync('token',token)
		},
		//退出登录
		userout(state){
			state.token = ''
			state.user = ''
			uni.removeStorageSync('user');
			uni.removeStorageSync('token');
		}
	},
    actions: {
		userout({commit}){
			commit('userout')
		},
    	
    }
})
export default store